package com.bwie.service.impl;

import com.bwie.mapper.CarMapper;
import com.bwie.pojo.Car;
import com.bwie.service.CarService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author GaoYiJie
 * @Description
 * @Create 2025/3/2 19:39
 * @Version 1.0
 */
@Service
public class CarServiceImpl implements CarService {

    @Autowired
    CarMapper carMapper;

    @Override
    public R getCarList() {
        List<Car> carList = carMapper.getCarList();
        return R.OK(carList);
    }

    @Override
    public R deleteByCarId(Integer carId) {
        carMapper.deleteById(carId);
        return R.OK(carId);
    }

    @Override
    public R updateCarSelect(Car car) {

        if (car.getCarSelect() == 1){
            //
        }else {
            car.setCarSelect(1);
        }
        carMapper.updateById(car);
        return R.OK();
    }

}
